﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.Windows.Forms;
using TRicheControl.Comm;

namespace TRicheControl.WinformControl
{
    [System.ComponentModel.DesignTimeVisible(false)]
    public partial class RicheMenuBarItem : Control
    {
        private Graphics mGraphics;

        public Graphics Graphics
        {
            get
            {
                if (base.IsDisposed)
                {
                    return null;
                }
                if (mGraphics == null)
                {
                    mGraphics = base.CreateGraphics();
                }
                return mGraphics;
            }
        }

        public RicheMenuBarItem()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            
        }

        //protected virtual 

        public virtual Size GetSize()
        {
            return new Size(0, 0);
        }
    }

    public class RicheMenuBarItemCollection : CollectionBase
    {
        private event Delegates.ItemChangeDelegate mOnItemChangeEvent;

        public event Delegates.ItemChangeDelegate OnItemChangeEvent
        {
            add 
            {
                mOnItemChangeEvent += value;
            }
            remove
            {
                mOnItemChangeEvent -= value;
            }
        }

        public RicheMenuBarItem this[int index]
        {
            get
            {
                return ((RicheMenuBarItem)List[index]);
            }
            set
            {
                List[index] = value;
            }
        }

        public int Add(RicheMenuBarItem value)
        {
            int index = List.Add(value);
            if (mOnItemChangeEvent != null)
            {
                mOnItemChangeEvent(ItemChangeType.Add, index);
            }
            return index;
        }

        public int IndexOf(RicheMenuBarItem value)
        {
            return (List.IndexOf(value));
        }

        public void Insert(int index, RicheMenuBarItem value)
        {
            List.Insert(index, value);
        }

        public void Remove(RicheMenuBarItem value)
        {
            int index = List.IndexOf(value);
            if (mOnItemChangeEvent != null)
            {
                mOnItemChangeEvent(ItemChangeType.Remove, index);
            }
            List.Remove(value);
        }

        public bool Contains(RicheMenuBarItem value)
        {
            return (List.Contains(value));
        }
    }
}
